package guiLayer.extensions;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.MatteBorder;

import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;

public class TreePanel extends JPanel {
	private static final long serialVersionUID = 1L;

	public TreePanel(String sort, String life, String km, String cost, String revenue, boolean isSelected) {
		setLayout(new BorderLayout(0, 0));
		JPanel treePanel = new JPanel();
		if(!isSelected){
			treePanel.setBorder(new MatteBorder(2, 2, 2, 2, (Color) new Color(100, 0, 0)));
		}else{
			treePanel.setBorder(new MatteBorder(0, 0, 1, 0, (Color) new Color(0, 0, 0)));
		}
		add(treePanel);
		treePanel.setLayout(new FormLayout(new ColumnSpec[] {
				ColumnSpec.decode("max(64px;default)"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(90dlu;default):grow"),},
			new RowSpec[] {
				RowSpec.decode("2px"),
				RowSpec.decode("64px"),
				RowSpec.decode("5px"),}));
		
		ImagePanel panel_1 = new ImagePanel();
		treePanel.add(panel_1, "1, 2, fill, fill");
		
		JPanel panel = new JPanel();
		treePanel.add(panel, "3, 2, fill, fill");
		panel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,},
			new RowSpec[] {
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JLabel lblSort = new JLabel(sort);
		lblSort.setFont(new Font("SansSerif", Font.BOLD, 12));
		lblSort.setHorizontalAlignment(SwingConstants.CENTER);
		panel.add(lblSort, "1, 1, 7, 1");
		
		JLabel lblNewLabel_1 = new JLabel("Lifespan:");
		panel.add(lblNewLabel_1, "1, 2");
		
		JLabel lblLifeSpan = new JLabel(life);
		panel.add(lblLifeSpan, "3, 2");
		
		JLabel lblNewLabel = new JLabel("Km2:");
		panel.add(lblNewLabel, "5, 2");
		
		JLabel lblSquareKilometer = new JLabel(km);
		panel.add(lblSquareKilometer, "7, 2");
		
		JLabel lblNewLabel_2 = new JLabel("Cost:");
		panel.add(lblNewLabel_2, "1, 4");
		
		JLabel lblCost = new JLabel(cost);
		panel.add(lblCost, "3, 4");
		
		JLabel lblNewLabel_3 = new JLabel("Revenue:");
		panel.add(lblNewLabel_3, "5, 4");
		
		JLabel lblRevenue = new JLabel(revenue);
		panel.add(lblRevenue, "7, 4");
	}
}
